<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('云商圈网点建档列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <input type="hidden" name="deptId" th:value="${deptId}"/>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="$.table.exportExcel()"
               shiro:hasPermission="merchant:branchMerchant:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var merchantTypeDatas = [[${@dict.getType('ecard_cust_type')}]];
    var overtimeFlag = [[${@permission.hasPermi('merchant:overtimeNotVisit:list')}]];
    var prefix = ctx + "ysqmap/info";

    $(function () {
        var options = {
            url: prefix + "/getBranchMerchantList",
            exportUrl: prefix + "/exportBranchMerchantList",
            id: "bootstrap-table",
            modalName: "网点建档商户信息",
            columns: [
                {
                    title: '序号',
                    align: "center",
                    formatter: function (value, row, index) {
                        return index+1;
                    }
                },
                /* {
                     field: 'deptId',
                     title: '机构编号'
                 },*/
                {
                    field: 'deptName',
                    title: '机构名称'
                },
                {
                    field: 'merchantType',
                    title: '客户类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(merchantTypeDatas, value);
                    }
                },
                {
                    field: 'merchantNum',
                    title: '建档数量',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.formatNumber(value);
                    }
                },
                {
                    field: 'merchantNumUnuse',
                    title: '已停用数量',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.formatNumber(value);
                    }
                },
                {
                    field: 'visitSum',
                    title: '拜访次数',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.formatNumber(value);
                    }
                },
                {
                    field: 'doTaskSum',
                    title: '超时拜访次数',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.formatNumber(value);
                    }
                },
                {
                    field: 'undoTaskSum',
                    title: '超时未拜访任务',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.formatNumber(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + overtimeFlag + '" href="javascript:void(0)" onclick="overtimeNotVisit(\'' + row.deptId + '\',\'' + row.merchantType + '\')"><i class="fa fa-edit"></i>超时未拜访明细</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    //超时未拜访明细
    function overtimeNotVisit(deptId, merchantType) {
        if (merchantType == '1'){//个人
            var url = '/merchant/branchPerson/perOvertimeNotVisit/' + deptId;
            $.modal.open("个人超时未拜访明细", url, '1400', '700');
        }
        if (merchantType == '2'){//商户
            var url = '/merchant/branchMerchant/overtimeNotVisit/' + deptId;
            $.modal.open("商户超时未拜访明细", url, '1400', '700');
        }
        if (merchantType == '3'){//企业
            var url = '/merchant/branchEnterprise/entOvertimeNotVisit/' + deptId;
            $.modal.open("企业超时未拜访明细", url, '1400', '700');
        }
        if (merchantType == '4'){//新型农业主体
            var url = '/merchant/branchAgriculture/agrOvertimeNotVisit/' + deptId;
            $.modal.open("新型农业主体超时未拜访明细", url, '1400', '700');
        }
    }
</script>
</body>
</html>